	var availableTags = [  ];
	var host="http://localhost:8080";
	var a = {};
	makeAutoCompleteActive();	
$(document).ready(function() {
	getSchoolTeachers();
	getClassesAndSections();
	getSubjectsForSchool();
});

function getClassesAndSections() {
	$.ajax({
				url : host+'/easyskool/rest/moderatorservice/getClassesAndSections',
				type : 'POST',
				data : '{}',
				dataType : 'json',
				contentType : "application/json; charset=utf-8",
				success : function(data, testStatus, response) {
					var jsondata = JSON.parse(response.responseText);
					var x = document.getElementById("classes");
					for(var i =0;i<jsondata.length;i++)
					{
						var option = document.createElement("option");
						option.text = jsondata[i].clsName+"-"+jsondata[i].clsSection;
						option.value=jsondata[i].classId;
						x.add(option);
//					alert("Class name "+jsondata[i].clsName);
					}
				}
			});
	
}

function getSchoolTeachers() {
	$.ajax({
				url :  host+'/easyskool/rest/moderatorservice/getSchoolTeachers',
				type : 'POST',
				data : '{}',
				dataType : 'json',
				contentType : "application/json; charset=utf-8",
				success : function(data, testStatus, response) {
					var jsondata = JSON.parse(response.responseText);
					for(var i =0;i<jsondata.length;i++)
					{
					availableTags.push(jsondata[i].teacherName);
					}
				}
			});
	
}
function getSubjectsForSchool() {
	$.ajax({
				url :  host+'/easyskool/rest/moderatorservice/getSubjectsForSchool',
				type : 'POST',
				data : '{}',
				dataType : 'json',
				contentType : "application/json; charset=utf-8",
				success : function(data, testStatus, response) {
					var jsondata = JSON.parse(response.responseText);
				 alert(jsondata);
					for(var i=0;i<jsondata.length;i++)
					{
					if(a[jsondata[i].suClassCode]==undefined)
						{a[jsondata[i].suClassCode] =jsondata[i].suName;
						}
					else
						a[jsondata[i].suClassCode]=a[jsondata[i].suClassCode]+","+jsondata[i].suName;
					}
				}
			});
	
}

function deleteExistingEntries()
{
	$('#assignmentTable').empty();
}
function makeAssignmentTable()
{
	deleteExistingEntries();
	var selectedClass=document.getElementById('classes').value;
	var subjects=a[selectedClass].split(",");
	for(var i=0;i<subjects.length;i++)
		{
	$('#assignmentTable').append('<tr class="child"><td>'+subjects[i]+'</td><td><div class="ui-widget"> <input class="tags"></div></td></tr>');
		}
	makeAutoCompleteActive();
	
}
 function makeAutoCompleteActive() {

	$(".tags").autocomplete({
		source : availableTags
	});
} 